package com.wp.service.impl;

import com.github.pagehelper.PageHelper;
import com.wp.dao.BooksDao;
import com.wp.domain.Books;
import com.wp.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 卫鹏
 * @Description books业务逻辑操作
 * @createTime 2021年10月26日 16:24:00
 */
@Service
public class BooksServiceImpl implements BooksService {
    @Autowired
    private BooksDao booksDao;

    @Override
    public List<Books> findAll(int page, int size) {
        PageHelper.startPage(page, size);
        return booksDao.findAll();
    }

    @Override
    public void insertBook(Books books) {
        booksDao.insertBook(books);
    }

    @Override
    public void deleteBook(String bookId) {
        //类型转换：
        int bookIdInt = Integer.parseInt(bookId);
        booksDao.deleteBook(bookIdInt);
    }

    @Override
    public void updateBook(Books book) {
        booksDao.updateBook(book);
    }

    @Override
    public Books findByBookId(String bookId) {
        //类型转换：
        int bookIdInt = Integer.parseInt(bookId);
        return booksDao.findByBookId(bookIdInt);
    }
}
